package b4.view.component.humanBeing
{
	import b4.util.BFont;
	
	import flash.events.MouseEvent;
	import flash.text.TextFormat;
	
	import org.aswing.ASColor;
	import org.aswing.FlowLayout;
	import org.aswing.JButton;
	import org.aswing.JPanel;
	import org.aswing.JTextField;
	
	public class PassDisaster extends HumanBaseTab
	
	{
//		任脉、督脉、冲脉、带脉、阴跷、阳跷、阴维、阳维,渡劫
		private var pulse:MeridiansPoint;
		private var renPulse:MeridiansPoint;
		private var duPulse:MeridiansPoint;
		private var chongPulse:MeridiansPoint;
		private var daiPulse:MeridiansPoint;
		private var yinQiao:MeridiansPoint;
		private var yangQiao:MeridiansPoint;
		private var yinWei:MeridiansPoint;
		private var yangWei:MeridiansPoint;
		private var dujie:MeridiansPoint;
		private var nameTxt:JTextField;
		private var effect:JTextField;
		private var nextLevel:JTextField;
		private var costGold:JTextField;
		private var needLevel:JTextField;
		private var costMeridians:JTextField;//经脉；
		private var lastTime:JTextField;
		private var speedUpPractice:JButton;
		private var passDisasterName:JTextField;
		private var pdCostMeridians:JTextField;
		private var passDisasterNow:JButton;
		public function PassDisaster()
		{
			super();
			renPulse = new MeridiansPoint(1);
			duPulse = new MeridiansPoint(2);
			chongPulse = new MeridiansPoint(3);
			daiPulse = new MeridiansPoint(4);
			yinQiao = new MeridiansPoint(5);
			yangQiao = new MeridiansPoint(6);
			yinWei = new MeridiansPoint(7);
			yangWei = new MeridiansPoint(8);
			dujie = new MeridiansPoint(9);
			renPulse.addEventListener(MouseEvent.CLICK, onClick);
			duPulse.addEventListener(MouseEvent.CLICK, onClick);
			chongPulse.addEventListener(MouseEvent.CLICK, onClick);
			yinQiao.addEventListener(MouseEvent.CLICK, onClick);
			yangQiao.addEventListener(MouseEvent.CLICK, onClick);
			yinWei.addEventListener(MouseEvent.CLICK, onClick);
			yangWei.addEventListener(MouseEvent.CLICK, onClick);
			dujie.addEventListener(MouseEvent.CLICK, onClick);
			daiPulse.addEventListener(MouseEvent.CLICK, onClick);
			leftPane.appendAll(renPulse, duPulse, chongPulse, daiPulse, yinQiao, yangQiao, yinWei, yangWei, dujie);
			nameTxt = getTxtfield("任脉:", 17, true);
			effect = getTxtfield("效果:");
			nextLevel = getTxtfield("下一等级:");
			costGold = getTxtfield("消耗金币:");
			needLevel = getTxtfield("需要等级:");
			costMeridians = getTxtfield("需要经脉:");
			lastTime = getTxtfield("剩余时间:");
			passDisasterName = getTxtfield("渡劫:");
			pdCostMeridians = getTxtfield("需要经脉:");
			var supPanel:JPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
			var pdnPanel:JPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
			speedUpPractice = new JButton("加速修炼");
			passDisasterNow = new JButton("立即渡劫");
			
			supPanel.append(speedUpPractice);
			pdnPanel.append(passDisasterNow);
			
			rightPane.appendAll(nameTxt, effect, nextLevel, costGold, costMeridians, 
							lastTime, supPanel, passDisasterName, pdCostMeridians, pdnPanel);
		}
			
		private function onClick(e:MouseEvent):void
		{
			var newPulse:MeridiansPoint = e.currentTarget as MeridiansPoint;
			nameTxt.setText("新脉:等级"+2);
			//一下从配置表得出；
			effect.setText("效果:"+"防御+30");
			needLevel.setText("下一等级:"+"防御+45");
			costGold.setText("消耗金币:"+33);
			needLevel.setText("需要等级:"+30);
			costMeridians.setText("需要经脉:"+"阳维等级2");
			lastTime.setText("剩余时间:"+"00:11:12");
			passDisasterName.setText("渡劫:"+"四九小天劫");
			pdCostMeridians.setText("需要经脉:"+"阳维等级2");
		}
		
		private function getTxtfield(title:String, size:int = 15, bold:Boolean = false):JTextField
		{
			var tx:JTextField = new JTextField();
			var textFormate:TextFormat = new TextFormat(BFont.DEFAULT_FONT, size,null, bold);
			tx.setDefaultTextFormat(textFormate);
			tx.setText(title);
			tx.setEditable(false);
			tx.setEnabled(false);
			tx.setBackground(ASColor.WHITE);
			tx.setBackgroundDecorator(null);
			tx.setPreferredHeight(30);
			return tx;
		}
	}
}
